'''
Copyright 2010 Indra Bagus <indra.bagus@gmail.com> 
    
Licensed under the Apache License, Version 2.0 (the "License"); 
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at 

    http://www.apache.org/licenses/LICENSE-2.0 
    
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. 
'''



from MACHeader import MACHeaderGeneric
from ManagementMessage import ULMap, DLMap
from ULMapIE import ULMapIEBurstProfile, ULMapIECDMABRequestAndRanging,\
    ULMapIECDMAAllocation, ULMapIEFastFeedBack
from DLMapIE import DLMapIEBurstProfiles, DLMapIECIDSwitch,\
    DLMapIEChannelMeasurement, DLMapIE_STC_DLZone, DLMapIE_AAS_DL,\
    DLMapIEDataLocAnotherBS, DLMapIEPhysicalModifier,\
    DLMapIEBroadcastCtrlPointer
from Type import WmxTLV

class Handler(object):
    def OnStartPDU(self,payload,macheader):
        assert(isinstance(payload,str))

    
    def OnEndPDU(self):
        pass

    
    def OnReceiveCRC(self,calc_crc,current_crc):
        pass

    
    def OnError(self,errstring):
        assert(isinstance(errstring,str))
        

    
class ULMAPHandler(Handler):
    def __init__(self):
        super(ULMAPHandler,self).__init__()
        
    
    def OnReceiveULMAP(self,ulmap):
        assert(isinstance(ulmap,ULMap))
    
    def OnReceiveULMAPIeFastFeedBack(self,ulmapie):
        assert(isinstance(ulmapie,ULMapIEFastFeedBack))
        
        
    def OnReceiveULMAPIeBurstProfile(self,ulmapie):
        assert(isinstance(ulmapie,ULMapIEBurstProfile))
    
    
    def OnReceiveULMAPIeRangingOpportunity(self,ulmapie):
        assert(isinstance(ulmapie, ULMapIECDMABRequestAndRanging))
    
    
    def OnReceiveULMAPIeCDMAAllocation(self,ulmapie):
        assert(isinstance(ulmapie, ULMapIECDMAAllocation))
    
    
    def OnReceivePowerControl(self,ulmapie): 
        pass
    
    
    def OnReceiveAAS_UL(self,ulmapie) : 
        pass
    
    
    def OnReceiveCQICHAlloc(self,ulmapie) : 
        pass
    
    
    def OnReceiveULZone(self,ulmapie) : 
        pass
    
    
    def OnReceivePhysicalModifier(self,ulmapie) : 
        pass
    
    
    def OnReceiveFastTracking(self,ulmapie) : 
        pass
    
    
    def OnReceiveULPUSCBurstAlloc(self,ulmapie) : 
        pass
    
    
    def OnReceiveFastRanging(self,ulmapie) : 
        pass
    
    
    def OnReceiveULAllocStart(self,ulmapie) : 
        pass
    
    
    def OnReceiveCQICHEnhancedAlloc(self,ulmapie): 
        pass
    
    
    def OnReceiveHOAnchorActive(self,ulmapie): 
        pass
    
    
    def OnReceiveHOActiveAnchor(self,ulmapie): 
        pass
    
    
    def OnReceiveAnchorBSSwitch(self,ulmapie): 
        pass
    
    
    def OnReceiveULSoundingCommand(self,ulmapie): 
        pass
    
    
    def OnReceiveExt2UIUC(self,ulmapie): 
        pass
    
    
    def OnReceiveMIMOULEnhanced(self,ulmapie): 
        pass
    
    
    def OnReceiveHARQULMapIE(self,ulmapie): 
        pass
    
    
    def OnReceiveHARQACKCHRegionAlloc(self,ulmapie): 
        pass
    
    
    def OnReceiveMIMOULBasicIE(self,ulmapie): 
        pass
    
    
    def OnReceiveMiniSubchanAlloc(self,ulmapie): 
        pass
    
    
    def OnReceiveULPCBitmap(self,ulmapie): 
        pass
    
    
    def OnReceivePersistentHARQ(self,ulmapie): 
        pass
    
    
    def OnReceiveFDDPairedAlloc(self,ulmapie): 
        pass
    
    
    def OnReceiveAASSDMA(self,ulmapie): 
        pass
    
    
    def OnReceiveFeedbackPolling(self,ulmapie): 
        pass    
    
    

class DLMAPHandler(Handler):
    def __init__(self):
        super(DLMAPHandler,self).__init__()
        
    def OnReceiveDLMAP(self,dlmap):
        assert(isinstance(dlmap,DLMap))

    
    def OnReceiveDLMAPIeBurstProfile(self,dlmapie):
        assert(isinstance(dlmapie,DLMapIEBurstProfiles))
    
    
    def OnReceiveDLMAPIeCIDSwitch(self,dlmapie):
        assert(isinstance(dlmapie,DLMapIECIDSwitch))
    
    
    def OnReceiveDLMAPIEChannelMeasurement(self,dlmapie):
        assert(isinstance(dlmapie,DLMapIEChannelMeasurement))
        
        
    def OnReceiveSTC_Zone(self,dlmapie):
        assert(isinstance(dlmapie,DLMapIE_STC_DLZone))
        
        
    def OnReceiveAASDL(self,dlmapie):
        assert(isinstance(dlmapie, DLMapIE_AAS_DL))
        
        
    def OnReceiveDataLocationAnotherBS(self,dlmapie):
        assert(isinstance(dlmapie,DLMapIEDataLocAnotherBS))
        
        
    def OnReceivePhysicalModifier(self,dlmapie):
        assert(isinstance(dlmapie,DLMapIEPhysicalModifier))        
        
        
    def OnReceiveBroadcastCtrlPointer(self,dlmapie):
        assert(isinstance(dlmapie,DLMapIEBroadcastCtrlPointer))



class UCDHandler(Handler):
    def OnReceiveUCD(self,ucd_header):
        pass
    
    def OnReceiveULBurstProfile(self,ulburstprofile):
        pass
    
    def OnReceiveULChannelEncoding(self,tlv):
        pass        
    


class DCDHandler(Handler):
    def OnReceiveDCD(self,dcd):
        pass
    
    def OnReceiveBurstProfile(self,burstprofile):
        pass
    
    def OnReceiveChannelEncoding(self,tlv):
        assert(isinstance(tlv,WmxTLV))        
        pass
    
    

class RangingHandler(Handler):
    def OnReceiveRanging(self,ranging):
        pass
    
    def OnReceiveTlvEncodedInfo(self,tlv):
        assert(isinstance(tlv,WmxTLV))
    
    

class RangingRequestHandler(RangingHandler):
    pass



class RangingResponseHandler(RangingHandler):
    pass



class DataHandler(Handler):
    pass



class MMHandlerCollection(object):
    def __init__(self):
        self.ulmaphandler   = ULMAPHandler()
        self.ucdhandler     = UCDHandler()
        self.dlmaphandler   = DLMAPHandler()
        self.dcdhandler     = DCDHandler()
        self.rngreqhandler  = RangingRequestHandler()
        self.rngrsphandler  = RangingResponseHandler()
        self.datahandler    = DataHandler()
        



